<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Language" content="en-us" />
		
		<title>Date Tests</title>
		
		<meta http-equiv="imagetoolbar" content="no" />
		<meta name="MSSmartTagsPreventParsing" content="true" />
		<meta name="Copyright" content="(c) 2007 Copyright content:  Copyright design: Luke Sutton" />
		
		<link rel="stylesheet" href="test.css" type="text/css" media="screen" charset="utf-8">
		
		<script type="text/javascript" language="javascript" charset="utf-8" src="../lib/prototype.js"></script>
		<script type="text/javascript" language="javascript" charset="utf-8" src="../lib/unittest.js"></script>
		<script type="text/javascript" language="javascript" charset="utf-8" src="../src/date.js"></script>
		
	</head>
	
	<body>	
	
    <h1>Date</h1>
		<div id="testlog"></div>
		<script type="text/javascript" language="javascript" charset="utf-8">
		// <![CDATA[
		  new Test.Unit.Runner({
		    testSet: function() { with(this) {
				var date =  new Date();
				date.set({year: 2000, month: 1, day: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0});
				assertEqual(new Date(2000, 0, 1, 0, 0, 0, 0).toString(), date.toString());
			}},
			testStartAndEnd: function() { with(this) {
				var dayStartMonthStart 	= new Date(2000, 1, 1, 0, 0, 0, 0); // tuesday, feb 2000, midnight
				var dayEndMonthStart 	= new Date(2000, 1, 1, 23, 59, 59, 999); // tuesday, feb 2000, very end of day
				var dayStartMonthEnd 	= new Date(2000, 1, 29, 0, 0, 0, 0);
				// Days
				
				// Months
				assertEqual(dayStartMonthStart.toString(), new Date(2000, 1, 1, 11, 0, 0, 0).startOfDay().toString());
				assertEqual(dayEndMonthStart.toString(), new Date(2000, 1, 1, 11, 0, 0, 0).endOfDay().toString());
				// Weeks
				// assertEqual(0, new Date(date.getTime()).startOfWeek().getDay());
				// assertEqual(6, new Date(date.getTime()).endOfWeek().getDay());
				// Months
				assertEqual(dayStartMonthStart.toString(), new Date(2000, 1, 11, 0, 0, 0, 0).startOfMonth().toString());
				assertEqual(dayStartMonthEnd.toString(), new Date(2000, 1, 11, 0, 0, 0, 0).endOfMonth().toString());
				// Years
				assertEqual(new Date(2000, 0, 1).toString(), new Date(2000, 5, 1).startOfYear().toString());
				assertEqual(new Date(2000, 11, 31).toString(), new Date(2000, 5, 1).endOfYear().toString());
			}},
			testNextPrevious: function() { with(this) {
				
			}},
			testBackwards: function() { with(this) {
				
			}},
			testForwards: function() { with(this) {
				
			}},
			testDaysInYear: function() { with(this) {
				// 2004 is a leap year, 2003 is not
				var leapYear = new Date(2004, 0, 1);
				var nonLeapYear = new Date(2003, 0, 1);
				assertEqual(366, leapYear.daysInYear());
				assertEqual(365, nonLeapYear.daysInYear());
			}},
			testLeapYear: function() { with(this) {
				// 2004 is a leap year, 2003 is not
				var leapYear = new Date(2004, 0, 1);
				var nonLeapYear = new Date(2003, 0, 1);
				assert(leapYear.isLeapYear());
				assertEqual(false, nonLeapYear.isLeapYear());
			}},
			testDaysInMonth: function() { with(this) {
				var january 			= new Date(2003, 0, 1);
				var febInALeapYear 		= new Date(2004, 1, 1);
				var febInNonLeapYear	= new Date(2003, 1, 1);
				var march				= new Date(2003, 2, 1);
				var april 				= new Date(2003, 3, 1);
				var may 				= new Date(2003, 4, 1);
				var june 				= new Date(2003, 5, 1);
				var july 				= new Date(2003, 6, 1);
				var august 				= new Date(2003, 7, 1);
				var september 			= new Date(2003, 8, 1);
				var october 			= new Date(2003, 9, 1);
				var november 			= new Date(2003, 10, 1);
				var december 			= new Date(2003, 11, 1);
				assertEqual(31, january.daysInMonth());
				assertEqual(29, febInALeapYear.daysInMonth());
				assertEqual(28, febInNonLeapYear.daysInMonth());
				assertEqual(31, march.daysInMonth());
				assertEqual(30, april.daysInMonth());
				assertEqual(31, may.daysInMonth());
				assertEqual(30, june.daysInMonth());
				assertEqual(31, july.daysInMonth());
				assertEqual(31, august.daysInMonth());
				assertEqual(30, september.daysInMonth());
				assertEqual(31, october.daysInMonth());
				assertEqual(30, november.daysInMonth());
				assertEqual(31, december.daysInMonth());
			}}
		  }, "testlog");
		// ]]>
		</script>
	
	</body>
</html>
